package com.rpc.framework;

/**
 * Description:
 * User: 27010
 * DateTime: 2017/8/20 11:37
 */
public class RpcConsumer {
	public static void main(String[] args) throws Exception {
//        HelloService service = RpcFramework.refer(HelloService.class, "127.0.0.1", 1234);
//        for (int i = 0; i < Integer.MAX_VALUE; i++) {
//            String hello = service.hello("World" + i);
//            System.out.println(hello);
//            Thread.sleep(1000);
//        }
		HelloService helloService = new HelloServiceImpl();
		ServiceInvocationHandler handler = new ServiceInvocationHandler("127.0.0.1", 99, helloService);
		HelloService service = RpcProxy.create(helloService.getClass(), handler);
		for (int i = 0; i < 100; i++) {
			String hello = service.hello("World" + i);
			System.out.println(hello);
			//Thread.sleep(1000);
		}
	}
}
